home *** CD-ROM | disk | FTP | other *** search
- /* Copyright © 1989 - 1990 by Apple Computer, Inc. All rights reserved. */
- /* UDemoText.p */
-
-
- /*
- This sample application demonstrates the breadth of alternatives
- available when using the MacApp building-block "UTEView" for text-editing.
- */
-
- #ifndef __DEMOTEXTDUMP__
- #include "DemoTextDump.h"
- #endif __DEMOTEXTDUMP__
-
-
- #define qDebug TRUE
-
- const unsigned long kSignature = 'SS04'; /* application signature */
- const unsigned long kFileType = 'TEXT'; /* file-type code for saved disk files --
- uses standard text files */
- const short kWindowRsrcID = 1004; /* 'view' template for a DemoText window */
- const short kViewRsrcID = 1005; /* 'view' template for a DemoText view */
-
- /* Additional document specifications */
- struct TextSpecs {
- Str255 theTextFont;
- Style theTextFace;
- short theTextSize;
- RGBColor theTextColor;
- short theJustification; /* record justification */
- RGBColor theBackColor; /* Window's background color */
- };
- typedef TextSpecs *TextSpecsPtr;
- typedef TextSpecsPtr *TextSpecsHdl;
-
- class TDemoTextApplication : public TApplication {
- public:
-
- virtual pascal void IDemoTextApplication(void);
- /* Initialize the Application */
-
- virtual pascal TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
- /* Launches a TTextDocument */
-
- #if qDebug
- virtual pascal void IdentifySoftware(void);
- #endif
-
- };
-
- class TTextDocument : public TDocument {
- public:
-
- Handle fDocText; /* The text owned by the document */
- TEStyleHandle fStyles; /* Style handle, if any */
- STHandle fElements; /* Handle to element array, if any */
- TTEView *fTEView; /* The view which displays the text */
-
- TextSpecs fTextSpecs; /* Specifies properties of the text */
-
- /* Initialization and freeing */
-
- virtual pascal void ITextDocument(void);
- virtual pascal void Free(void);
- virtual pascal void DoInitialState(void);
- virtual pascal void FreeData(void);
-
- /* Filing */
-
- virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
- virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
- virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
-
- /* Making views and windows */
-
- virtual pascal void DoMakeViews(Boolean forPrinting);
-
- /* Command processing */
-
- virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- virtual pascal void DoSetupMenus(void);
-
- /* Auxiliary routines */
-
- virtual pascal void ChangeBackColor(RGBColor *newColor);
-
- virtual pascal void SetSpecStyle(void);
-
- virtual pascal void ShowReverted(void);
- /* When the user reverts a document, this is called after reading
- the old document and before displaying it. Causes the reverted
- font specs to be installed. */
-
- /* Debugging */
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
-
- };
-
- class TJustCommand : public TCommand {
- public:
- TTEView *fTEView;
- short fOldJust;
- short fNewJust;
-
- virtual pascal void IJustCommand(TTEView *itsTEView, short itsNewJust);
-
- virtual pascal void DoIt(void);
-
- virtual pascal void RedoIt(void);
-
- virtual pascal void UndoIt(void);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- };
-